/*
 *      Created on: Feb 24, 2011
 *      Author: topcoder
 */

#ifndef Measure_H_
#define Measure_H_

#include <Unit.h>
#include <string>

template <class UnitType> class Measure
{
    public:
        Measure(unsigned long quantity, const UnitType& unit);
        bool    operator == (const Measure& measure)const;
        Measure operator + (const Measure& measure)const;
        string print(const UnitType& unit);

    private:
        Measure(unsigned long quantity);
        unsigned long quantity_m;
};

template <class UnitType> Measure<UnitType>::Measure(unsigned long quantity, const UnitType& unit)
{
    quantity_m = unit.convertToBase(quantity);
}

template <class UnitType> string Measure<UnitType>::print(const UnitType& unit)
{
    return (UnitType::print(quantity_m, unit));
}

template <class UnitType> bool Measure<UnitType>::operator == (const Measure &measure)const
{
    return (quantity_m == measure.quantity_m);
}

template <class UnitType> Measure<UnitType> Measure<UnitType>::operator + (const Measure &measure)const
{
    return Measure(quantity_m + measure.quantity_m);
}

template <class UnitType> Measure<UnitType>::Measure(unsigned long quantity):quantity_m(quantity)
{
}


#endif /* Measure_H_ */
